//
// Created by zhanggang on 24-5-25.
//

#ifndef GUESSING_NUMBERS_H
#define GUESSING_NUMBERS_H
#include <iostream>
#include <ostream>
#include <cstdlib>
//#include <random>
using namespace std;


inline void guessing_numbers() {
    int count = 0;
    int numbers;
    //在程序开始时设置种子
    srand(time(0));
    int rand_numbenrs = rand() % 101;
    cout << rand_numbenrs << endl;
    cout << "请输入你的猜测数字:" << endl;
    cin >> numbers;
    while (true) {
        if (rand_numbenrs == numbers) {
            count++;
            cout << "恭喜你猜对了,一共用了" + to_string(count) + "次" << endl;
            break;
        } else if (rand_numbenrs > numbers) {
            count++;
            cout << "猜小了" << endl;
            cout << "请重新输入你的猜测数字:,一共用了" + to_string(count) + "次" << endl;
            cin >> numbers;
        } else if (rand_numbenrs < numbers) {
            count++;
            cout << "猜大了" << endl;
            cout << "请重新输入你的猜测数字:,一共用了" + to_string(count) + "次" << endl;
            cin >> numbers;
        }
    }
}

#endif //GUESSING_NUMBERS_H
